package zhaoshengxing;

import java.util.Random;
import java.util.Scanner;

public class DoubleColorBall {
    public static void main(String[] args) {
        int[] win1 = win();                                                 //中奖号码
        int[] win2 = input();                                               //用户输入的号码
        int count = 0, blue = 0;
        for (int i = 0; i < win1.length - 1; i++) {
            if (win1[i] == win2[i]) {
                count++;                          //记录红色中将的数量
            }
        }
        if (win1[6] == win2[6]) {
            blue++;                               //蓝色是否中奖
        }

        System.out.println("中奖号码为：");
        for (int k : win1) {
            System.out.print(k + "\t");
        }
        System.out.println("您投注的号码为：");
        for (int j : win1) {
            System.out.print(j + "\t");
        }

        System.out.println("您中的红色小球数为：" + count + "个         中的蓝色小球数为：" + blue + "个");
        if (count==6 && blue==1) {                                           //中奖判断
            System.out.println("中奖最高1000万");
        } else if (count==6 && blue==0) {
            System.out.println("中奖最高500万");
        }else if (count==5 && blue==1) {
            System.out.println("中奖3000元");
        }else if (count==5 && blue==0||count==4&&blue==1) {
            System.out.println("中奖200元");
        }else if (count==4 && blue==0||count==3&&blue==1) {
            System.out.println("中奖10元");
        }
        else if (count==1 && blue==1||count==2&&blue==1||count==0&&blue==1) {
            System.out.println("中奖5元");
        }
        else {
            System.out.println("您未中奖");
        }

    }



    public static int[] win() {                                 //随机生成六位不同的数
        int[] win = new int[7];
        Random rd = new Random();
        int count = 1;                                        //用来判断是否有相同
        for (int i = 0; i < win.length - 1; i++) {
            do {
                win[i] = rd.nextInt(33) + 1;
                for (int j = 0; j < i; j++) {
                    if (win[i] == win[j]) {
                        count = 0;
                        break;
                    }
                }
            } while (count == 0);                                 //遍历已生成数组，判断随机数是否相同，如果相同再循环一次重新生成
        }
        win[6] = rd.nextInt(16) + 1;                     //生成蓝色小球
        return win;
    }

    public static int[] input() {                   //客户自己输入双色球
        int[] input1 = new int[7];
        Scanner sc = new Scanner(System.in);
        for (int i = 0; i < input1.length; i++) {
            if (i <= input1.length - 2) {
                System.out.println("输入任意一个范围1-33的数字：");
            } else {
                System.out.println("输入任意一个范围1-16的数字：");
            }
            input1[i] = sc.nextInt();
        }
        return input1;
    }

}
